<template>
	<view class="textpage">
		<!-- 头部 -->
		<view class="homelife_head">
			<view v-for="(item,index) in headlist" :key="index" class="container_headbox" @click="Onhead(item)">
				<text
					:class="headindex == item.id?'head_titlea':'head_titleb'">{{item.title}}(<text>{{item.num}}</text>)</text>
				<view v-if="headindex == item.id"></view>
			</view>
		</view>
		<!-- 内容 -->
		<LoadMore ref="LoadMore" id="LoadMore" :diffHeight="124" :initData="initData" @dataRefresh='dataRefresh'
			@infoRefresh='infoRefresh'>
			<text></text>
			<view class="content" v-for="(item,index) in list" :key="index"  @click="Onjump(item)">
				<view class="content_top font14">
					<text class="font-323232">{{item.createtime}}</text>
					<view class="font-ffffff">
						{{item.typename}}
					</view>
				</view>
				<view class="cleaning_bos">
					<image class="cleaning_image" mode="aspectFill" src="../../static/my/portrait.png">
					</image>
					<view class="cleaning_box">
						<view class="font14 font-323232">{{item.user_the_patient_info.name}}
							{{item.user_the_patient_info.sex==1?'男':'女'}}
							{{item.user_the_patient_info.age}}岁
						</view>
						<!-- <view class="font14 font-323232">排队序号:123</view> -->
						<view class="ellipsis font13 font-969696">问题描述:{{item.content?item.content:'暂无'}}</view>
					</view>
				</view>
				<!-- <view class="content_button font-ffffff font14">
					<view @click="Ontextinfo(item)" class="back_8d8d8d">查看问题单</view>
					<view v-if="item.status == 'normal'" @click="Ontrue(item,'refuse')" class="back_e51c42">拒绝接诊</view>
					<view v-if="item.status == 'normal'" @click="Ontrue(item,'confirm')" class="back_80a505">确认接诊</view>
					<view v-if="item.status == 'patient'" @click="Ontrue(item,'end')" class="back_80a505">确认完成</view>
					<view v-if="item.status == 'patient'" @click="Onjump(item)" class="back_80a505">进入聊天室</view>
				</view> -->
			</view>
		</LoadMore>
	</view>
</template>

<script>
	import LoadMore from "@/components/loadMore.vue";
	export default {
		components: {
			LoadMore
		},
		data() {
			return {
				//传参数据
				initData: {
					url: 'doctorlistConsultationVideoOrder', //接口
					//data里得传参
					param: {
						status: 'normal'
					},
				},
				list: [],
				headindex: 1, //下标显示
				//头部列表
				headlist: [{
						num: 0,
						title: '待咨询',
						id: 1,
						code: 'normal'
					}, {
						num: 0,
						title: '咨询中',
						id: 2,
						code: 'patient'
					},
					{
						num: 0,
						title: '已完成',
						id: 3,
						code: 'end'
					}
				],
			}
		},
		methods: {
			//返回数据
			dataRefresh(e) {
				e.forEach(item => {
					item.createtime = this.$base.formatTime(new Date(item.createtime *
						1000), "yyyy/MM/dd hh:mm:ss")
					item.user_the_patient_info.age = this.$base.Onage(item.user_the_patient_info.birthday)
					if (item.pay_status == 2) {
						if (item.status == 'normal') {
							item.typename = '待支付'
						}
						if (item.status == 'cancel') {
							item.typename = '已取消'
						}
						item.status_is = false
					}
					if (item.pay_status == 1) {
						item.status_is = true
						if (item.status == 'normal') {
							item.typename = '待接诊'
						}
						if (item.status == 'refund') {
							item.typename = '已退款'
							item.status_is = false
						}
						if (item.status == 'refuse_patient') {
							item.typename = '拒绝接诊'
						}
						if (item.status == 'patient') {
							item.typename = '接诊中'
						}
						if (item.status == 'end') {
							item.typename = '接诊完成'
						}
						if (item.status == 'comment') {
							item.typename = '已评论'
						}
					}
				})
				this.list = e
			},
			//切换
			Onhead(res) {
				this.headindex = res.id
				this.initData.param.status = res.code
				this.$refs.LoadMore.oncutRefresh(this.initData)
			},
			//详情
			Ontextinfo(e) {
				uni.navigateTo({
					url: '/pagesA/doctor/textinfo?id=' + e.id + '&type=sp',
				})
			},
			//操作
			Ontrue(obj, type) {
				let that = this
				let url = ''
				let content = ''
				if (type == 'confirm') {
					content = '您确定要接诊吗'
					url = 'consultationVideoPatient'
				}
				if (type == 'refuse') {
					content = '您确定要拒绝接诊吗'
					url = 'consultationVideoRefusePatient'
				}
				if (type == 'end') {
					content = '您确定要完成接诊吗'
					url = 'videoEndPatient'
				}

				uni.showModal({
					title: '操作提示',
					confirmText: '确定',
					confirmColor: '#b8875c',
					cancelText: '取消',
					content: content,
					success: function(res) {
						if (res.confirm) {
							that.$Http({
								url: url,
								data: {
									order_id: obj.id
								},
								type: 'POST',
							}).then(res => {
								if (res.code == 1) {
									that.$refs.LoadMore.oncutRefresh(that.initData)
								}
							});
						}
					}
				});
			},
			//对象的返回
			infoRefresh(e) {
				this.headlist[0].num = e.normal_count
				this.headlist[1].num = e.patient_count
				this.headlist[2].num = e.end_count
			},
			Onjump(e) {
				uni.navigateTo({
					// url: '/pagesA/common/video?id=' + e.id + '&type=doc',
					url: '/pagesA/message/chat?isDoc=1&cate=video&orderno='+e.order_code
				})
			}
		}
	}
</script>

<style>
	/* 头部 */
	.homelife_head {
		height: 124rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.container_headbox {
		height: 50rpx;
	}

	.head_titlea {
		font-size: 30rpx;
		font-weight: 700;
		color: #323232;
	}

	.head_titleb {
		font-size: 30rpx;
		color: #969696;
	}

	.container_headbox view {
		height: 5rpx;
		background-color: #6bcbb6;
		border-radius: 3px;
		margin-top: 12rpx;
	}

	/* 内容区域 */
	.content {
		width: 690rpx;
		background-color: #ffffff;
		box-shadow: 0px 3rpx 30rpx 0px rgba(168, 168, 168, 0.15);
		border-radius: 5rpx;
		margin: 0rpx 30rpx 50rpx 30rpx;
		padding: 28rpx 24rpx;
	}

	.content_top {
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx #eeeeee solid;
		padding-bottom: 18rpx;
	}

	.content_top view {
		background-color: #80a505;
		padding: 6rpx 10rpx;
		border-radius: 10rpx;
	}

	.cleaning_bos {
		padding: 40rpx 0;
		border-bottom: 1rpx #eeeeee solid;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.cleaning_image {
		width: 132rpx;
		height: 132rpx;
		border: 66rpx;
		border-radius: 10rpx;
	}

	.cleaning_box {
		width: 500rpx;
		height: 132rpx;
		padding-left: 27rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
	}

	.content_button {
		display: flex;
		align-items: center;
		justify-content: space-around;
		padding-top: 28rpx;
	}

	.content_button view {
		padding: 6rpx 10rpx;
		border-radius: 10rpx;
	}

	.back_8d8d8d {
		background-color: #8d8d8d;
	}

	.back_e51c42 {
		background-color: #e51c42;
	}

	.back_80a505 {
		background-color: #80a505;
	}
</style>
